<template>
  <header class="header">
    <h1>任务列表</h1>
    <input
      class="new-todo"
      placeholder="请输入要做的事情"
      autofocus
      v-model="todo"
      @keyup.enter="add"
    />
  </header>
</template>

<script>
export default {
  data() {
    return { todo: "" };
  },
  methods: {
    add() {
      this.$emit("add", this.todo);
      //清空输入框
      this.todo = "";
    },
  },
};
</script>

<style>
</style>